package com.wjb.xietong.server.taskReply;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.wjb.xietong.server.IRequestParam;
import com.wjb.xietong.util.IDs;

public class TaskReplyParam implements IRequestParam {

	private long companyId = 0l;
	private long projectId = 0l;
	private long userId = 0l;
	private long taskId = 0l;
	private List<String> notifyUserIDList = null;// 要通知的用户id
	private String content = null;// 回复内容
	private List<FileInfo> fileInfoList = null;// 附件内容信息

	@Override
	public Map<String, String> parseData2Map() {
		Map<String, String> map = new HashMap<String, String>();
		put(map, IDs.M, IDs.ADD_WORK_SYS_TASK);
		put(map, IDs.COM_ID, getCompanyId());
		put(map, IDs.USER_ID, getUserId());
		put(map, IDs.TASK_ID, getTaskId());
		put(map, IDs.PROJECT_ID, getProjectId());

		String str = null;
		if (null != getNotifyUserIDList()) {
			for (String notifyUserId : getNotifyUserIDList()) {
				if (null == str) {
					str = notifyUserId;
				} else {
					str += "," + notifyUserId;
				}
			}
		}
		put(map, IDs.STR, str);

		String replyContent = null;
		if (null != getContent()) {
			replyContent = "<p>" + getContent() + "</p>";
		}
		
		if(null != getFileInfoList()){
			for(FileInfo fileInfo : getFileInfoList()){
				if(null == replyContent){
					replyContent = "";
				}
				replyContent += "<p><img alt=\"" + fileInfo.getFileName() + "\" ";
				replyContent += "src=\"" + fileInfo.getFilePath() + "\" ";
				replyContent += "data-image-size=\"" + fileInfo.getImageWidth() + "," + fileInfo.getImageHeight() + "\" ";
				replyContent += "style=\"max-width: 100\"><br></p>";
			}
		}
		put(map, IDs.CONTENT, replyContent);
		return map;

	}
	
	private void put(Map<String, String> map, String key, long value) {
		put(map, key, String.valueOf(value));
	}

	private void put(Map<String, String> map, String key, String value) {
		if (null == key || null == value) {
			return;
		}
		map.put(key, value);
	}

	public static class FileInfo {
		private String fileName = null;// 文件名称
		private String filePath = null;// 图片网络地址
		private long fileSize = 0l;// 文件大小
		private int imageHeight = 0;// 图片高度
		private int imageWidth = 0;// 图片宽度

		public String getFileName() {
			return fileName;
		}

		public void setFileName(String fileName) {
			this.fileName = fileName;
		}
		
		public String getFilePath() {
			return filePath;
		}

		public void setFilePath(String filePath) {
			this.filePath = filePath;
		}

		public long getFileSize() {
			return fileSize;
		}

		public void setFileSize(long fileSize) {
			this.fileSize = fileSize;
		}

		public int getImageHeight() {
			return imageHeight;
		}

		public void setImageHeight(int imageHeight) {
			this.imageHeight = imageHeight;
		}

		public int getImageWidth() {
			return imageWidth;
		}

		public void setImageWidth(int imageWidth) {
			this.imageWidth = imageWidth;
		}

	}

	public long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(long companyId) {
		this.companyId = companyId;
	}

	public long getProjectId() {
		return projectId;
	}

	public void setProjectId(long projectId) {
		this.projectId = projectId;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public long getTaskId() {
		return taskId;
	}

	public void setTaskId(long taskId) {
		this.taskId = taskId;
	}

	public List<String> getNotifyUserIDList() {
		return notifyUserIDList;
	}

	public void setNotifyUserIDList(List<String> notifyUserIDList) {
		this.notifyUserIDList = notifyUserIDList;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public List<FileInfo> getFileInfoList() {
		return fileInfoList;
	}

	public void setFileInfoList(List<FileInfo> fileInfoList) {
		this.fileInfoList = fileInfoList;
	}
}
